package com.hancher.gamelife2.picturecombine;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.hancher.common.rv.BaseVBAdapter;
import com.hancher.gamelife2.databinding.ItemImageSelectBinding;

import java.io.File;

import lombok.AllArgsConstructor;
import lombok.Data;

public class PictureCombineAdapter extends BaseVBAdapter<ItemImageSelectBinding, PictureCombineAdapter.ImageSelectItem> {

    public PictureCombineAdapter() {
    }

    @Override
    protected ItemImageSelectBinding createViewBinding(LayoutInflater from, ViewGroup viewGroup) {
        return ItemImageSelectBinding.inflate(from, viewGroup, false);
    }

    @Override
    protected void convertItem(ItemImageSelectBinding binding, int position, ImageSelectItem item) {

        binding.imgItemSelect.setVisibility(item.isSelect() ? View.VISIBLE : View.GONE);
        binding.imgItemSelect2.setVisibility(item.isSelect() ? View.GONE : View.VISIBLE);

        ImageView image = item.isSelect() ? binding.imgItemSelect : binding.imgItemSelect2;
        Glide.with(image).load(new File(item.getImgPath())).into(image);
    }

    @Data
    @AllArgsConstructor
    public static class ImageSelectItem {
        private String imgPath;
        private boolean isSelect = true;
    }
}
